{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "3a79ef54-63e6-429f-ba9f-590b736a7f29",
   "metadata": {},
   "source": [
    "## 1.2 使用Pyhton虚拟环境"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "c90a18b9-d8e8-431c-856c-35f1e4ed05e1",
   "metadata": {},
   "source": [
    "### 1.任务描述\n",
    "- 在指定目录（D:\\deve\\Python）下创建虚拟环境venv1和venv2。\n",
    "- 激活venv1，在venv1下安装NumPy包，查看venv1下的所有包，退出venv1。\n",
    "- 激活venv2，在venv2下安装pandas包，查看venv2下的所有包，退出venv2。2。"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "f1496e9f-1c91-4791-b744-30c00bdc3de0",
   "metadata": {},
   "source": [
    "### 2.知识准备\n",
    "\n",
    "见教程。\n"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "6b0dbd28-6fec-4304-bc97-1f74fbb0439f",
   "metadata": {},
   "source": [
    "### 3.任务分析\n",
    "\n",
    "自Python3.3版本之后，venv已经作为标准库嵌入到Python中，可以使用venv创建虚拟环境。语法如下："
   ]
  },
  {
   "cell_type": "raw",
   "id": "4146d83b-1679-431d-ad20-48f39f335358",
   "metadata": {},
   "source": [
    "python -m venv <虚拟环境名称>"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "435c6090-cfda-4f46-a550-22a368e41e4a",
   "metadata": {},
   "source": [
    "### 4.任务实施\n",
    "\n"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "ec75eb6c-5da3-467d-a471-ca3b47242dd6",
   "metadata": {},
   "source": [
    "1. 创建虚拟环境venv1和venv2\n",
    "\n",
    "切换到D:\\deve\\Python目录，打开“命令提示窗口”，使用如下命令创建虚拟环境："
   ]
  },
  {
   "cell_type": "raw",
   "id": "febafc02-eed4-4c77-b241-0a825425a895",
   "metadata": {},
   "source": [
    "D:\\deve\\Python>python -m venv venv1\n",
    "D:\\deve\\Python>python -m venv venv2\t"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "92c8ce99-8793-4da2-a3e0-ec20ab1c4659",
   "metadata": {},
   "source": [
    "2. 激活虚拟环境venv1，安装NumPy，查看包并退出\n",
    "\n",
    "切换到虚拟环境目录venv1下的Scripts目录，打开“命令提示窗口”，执行命令："
   ]
  },
  {
   "cell_type": "raw",
   "id": "d5851eae-461a-42db-bdb3-ed4bbf969ec8",
   "metadata": {},
   "source": [
    "D:\\deve\\Python\\venv1\\Scripts>activate\n",
    "(venv1) D:\\deve\\Python\\venv1\\Scripts>pip install numpy\n",
    "(venv1) D:\\deve\\Python\\venv1\\Scripts>pip list\n",
    "(venv1) D:\\deve\\Python\\venv1\\Scripts>deactivate.bat"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "c8f95bbc-5dcd-4920-bb0a-f78febb22eb5",
   "metadata": {},
   "source": [
    "3. 激活虚拟环境venv2，安装pandas，查看包并退出\n",
    "\n",
    "切换到虚拟环境目录venv2下的Scripts目录，打开“命令提示窗口”，执行命令："
   ]
  },
  {
   "cell_type": "raw",
   "id": "cea85882-4e24-4a90-a91c-903885287e0f",
   "metadata": {},
   "source": [
    "D:\\deve\\Python\\venv2\\Scripts>activate\n",
    "(venv2) D:\\deve\\Python\\venv2\\Scripts>pip install pandas\n",
    "(venv2) D:\\deve\\Python\\venv2\\Scripts>pip list\n",
    "(venv2) D:\\deve\\Python\\venv2\\Scripts>deactivate.bat"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "912c4271-6225-4a7e-a46e-bff26c0508e3",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.10"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
